package com.server.questionbank.snframe.service;

import com.server.questionbank.snframe.domain.TCollection;
import com.server.questionbank.snframe.mapper.TCollectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TCollectionServiceImpl implements TCollectionService {
    @Autowired
    public TCollectionMapper tCollectionMapper;

    // 查询收藏记录
    @Override
    public TCollection selectCollection(Long userId, Long targetId, String targetType) {
        return tCollectionMapper.selectCollectionByUserAndTarget(userId, targetId, targetType);
    }
    @Override
    public List<TCollection> selectCollection(Long userId, String targetType) {
        return tCollectionMapper.selectCollectionsByUserAndType(userId, targetType);
    }
    @Override
    public List<TCollection> selectCollection(Long userId) {
        return tCollectionMapper.selectCollectionsByUser(userId);
    }
    @Override
    public TCollection selectCollectionById(Long collectionId) {
        return tCollectionMapper.selectCollectionById(collectionId);
    }

    // 插入收藏记录
    @Override
    public Integer insertCollection(Long userId, Long targetId, String targetType) {
        return tCollectionMapper.insertCollection(userId, targetId, targetType);
    }

    // 删除收藏记录
    @Override
    public Integer deleteCollection(Long collectionId) {
        return tCollectionMapper.deleteCollection(collectionId);
    }
}
